package com.nondo.rdp.finance.domain.setting.home;

import com.nondo.rdp.core.domain.attach.Attach;
import com.nondo.rdp.core.domain.base.BaseEntity;
import com.nondo.rdp.finance.config.DbConfig;
import org.hibernate.validator.constraints.Length;

import javax.persistence.*;
import javax.validation.constraints.NotNull;

/**
 * 设置模块
 */
@Entity
@Table(name = DbConfig.DEFAULT_TABLE_PREFIX + "setting_module")
public class SettingModule extends BaseEntity {
    public final static String TYPE_SLIDE = "slide";
    public final static String TYPE_EDUCATION = "education";
    public final static String TYPE_SECURITY_OPEN = "securityOpen";
    public final static String TYPE_NOTICE = "notice";
    public final static String TYPE_ICON = "icon";
    public final static String TYPE_PRODUCT = "product";
    public final static String TYPE_CUSTOMER = "customer";

    private Long id;    //自增ID
    private String title;   //模块名字
    private Attach icon;    //模块icon
    private String moduleType; //模块类型，即模块约定名字，不可更改，slide=幻灯片，education=教育，securityOpen=证券开户,notice=公告，icon=图标，customer=自定义模块
    private int sort; //模块排序
    private int status; //状态，0=开启，1=关闭
    private int type; //更多打开类型，0=不展示不操作，1=打开url地址，10=打开分析列表，11=打开分析详情，20=打开课程列表，21=打开课程详情，22=打开自定义课程，30=打开活动列表
    private String value; //对应更多打开类型的值
    private int style; //模块展示样式
    private int isShare;//特殊字段，判断是内容是否可以分享，0=不能分享，1=可以分享

    @Id
    @GeneratedValue(strategy = GenerationType.AUTO)
    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    @NotNull(message = "标题不能为空")
    @Length(min = 1, max = 32, message = "标题长度不能超过32个字符")
    @Column(name = "title", length = 32)
    public String getTitle() {
        return title;
    }

    public void setTitle(String title) {
        this.title = title;
    }

    @OneToOne(cascade = CascadeType.ALL)
    @JoinColumn(name = "icon")
    public Attach getIcon() {
        return icon;
    }

    public void setIcon(Attach icon) {
        this.icon = icon;
    }

    @NotNull(message = "模块类型不能为空")
    public String getModuleType() {
        return moduleType;
    }

    public void setModuleType(String moduleType) {
        this.moduleType = moduleType;
    }


    @Column(columnDefinition = "int default 1")
    public int getSort() {
        return sort;
    }

    public void setSort(int sort) {
        this.sort = sort;
    }

    @Column(columnDefinition = "int default 0")
    public int getStatus() {
        return status;
    }

    public void setStatus(int status) {
        this.status = status;
    }

    @Column(columnDefinition = "int default 0")
    public int getType() {
        return type;
    }

    public void setType(int type) {
        this.type = type;
    }

    public String getValue() {
        return value;
    }

    public void setValue(String value) {
        this.value = value;
    }

    @Column(columnDefinition = "int default 0")
    public int getStyle() {
        return style;
    }

    public void setStyle(int style) {
        this.style = style;
    }

    @Column(columnDefinition = "int default 0")
    public int getIsShare() {
        return isShare;
    }

    public void setIsShare(int isShare) {
        this.isShare = isShare;
    }
}